OTAccept
Accepts an incoming connection request.C INTERFACE
OSStatus OTAccept(EndpointRef ref, EndpointRef resRef, TCall* call);C++ INTERFACE
OSStatus TEndpoint::Accept(EndpointRef resRef, TCall* call);PARAMETERS
ref
- The endpoint reference of the listening endpoint.
resRef
- The endpoint reference of the endpoint accepting the connection.
call
- A pointer to a
TCall
structure (page 3-62) that contains information about the address of the peer requesting the connection, option information, data associated with
the connection request, and the connection ID for this connection.DESCRIPTION
You use theOTAccept
function to accept a request that you retrieved using theOTListen
function. You can accept a connection on either the same or on a different endpoint than the one listening for connection request.
If you do not wish to accept the request, you must call the
- If you accept the connection on the same endpoint (the values of the
ref
andresRef
parameters are the same), there must be no other outstanding connection requests on that endpoint. Otherwise, the call toOTAccept
fails and returns thekOTIndOutErr
result.- If you accept the connection on a different endpoint (the values of the
ref
andresRef
parameters are different), you are not required to bind the endpoint accepting the request first. If the endpoint is not bound, the provider binds it to the same address as that of the endpoint receiving the connection request. If you want to bind it explicitly to that address, you must set thereqAddr->qlen
field to 0 and the endpoint must be in theT_IDLE
state before calling theOTAccept
function. If you want to bind it to a different address, there are no restrictions on the value of theeqAddr->qlen
field.
OTSndDisconnect
function.If the endpoint is in asynchronous mode, the
OTAccept
function returns immediately with akOTNoError
result, indicating that processing has begun and that the client will be notified when it is complete.When processing is finished and the connection is opened, the provider for the endpoint specified by the
ref
parameter, calls that endpoint's notifier, passingT_ACCEPTCOMPLETE
for thecode
parameter andkInvalidEndpointRef
for thecookie
parameter. The provider for the endpoint specified by theresRef
parameter, calls that endpoint's notifier, passingT_PASSCON
for thecode
parameter andref
for thecookie
parameter. If you have accepted the connection on the same endpoint (ref
andresRef
are the same), the provider issues theT_ACCEPTCOMPLETE
event first, and then theT_PASSCON
event.If you have not installed a notifier, you can poll the endpoint accepting the connection for a change of state to
T_DATAXFER
; the change of state happens when the connection is opened.SPECIAL CONSIDERATIONS
In asynchronous mode, it is possible for the endpoint to issue theT_ACCEPTCOMPLETE
event before theOTAccept
function returns thekOTNoError
result.Not all endpoints support the sending of data with a connection request. Examine the
connect
field of theTEndpointInfo
structure for the endpoint to determine if the endpoint supports the sending of data and the maximum size of the data.The
OTAccept
function fails with thekOTLookErr
error if there are indications (T_DISCONNECT
orT_LISTEN
) waiting to be received. This is becauseCalling the
OTAccept
function on an endpoint that was bound with aqlen
greater than 1 can result in akOTLookErr
being returned because anotherT_LISTEN
event has arrived. Unfortunately, XTI specifies that the accept request cannot be acted on until theOTListen
function has been called to receive this new connection request. This effectively means that you need to keep an array of outstanding connection requests. If you are acting onT_LISTEN
events in your notifier, then you need to be able to handle having as many outstanding connection requests as you indicate in theqlen
field, issuing an accept request, and getting aT_LISTENCOMPLETE
event before theT_ACCEPTCOMPLETE
event returns to you.COMPLETION EVENT CODES
T_ACCEPTCOMPLETE
0x20000003 The OTAccept
function has completed. Thecookie
parameter of the notifier function contains the endpoint reference of the endpoint to which the connection has been passed.VALID STATES
Endpoint specified by theref
parameter:T_INCON
Endpoint specified by the
resRef
parameter:T_IDLE
orT_UNBND
SEE ALSO
You use theOTListen
function (page 3-125) to read a connection request before calling theOTAccept
function to accept the request.You use the
TCall
structure (page 3-62) to store information about the address of the peer requesting the connection, option information, data associated with the connection request, and the connection ID for this connection.You use the
OTBind
function (page 3-77) to bind the endpoint accepting the request explicitly and to specify the number of connection requests that can be outstanding for the endpoint.You use the
OTSndDisconnect
function (page 3-149) to reject an incoming connection request.For information on how to use this function with a TCP/IP protocol, see page 8-18 in the TCP/IP chapter.
You examine the
connect
field of theTEndpointInfo
structure (page 3-48) to determine whether your endpoint supports the sending of data with a connection request.